package com.onegroup.controller;

import com.onegroup.pojo.Application;
import com.onegroup.pojo.ResponseResult;
import com.onegroup.pojo.vo.ApplicationVo;
import com.onegroup.service.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author: 曾雪斌
 * @Description: 统一身份认证管理Controller层
 * @History:
 */
@RestController
@RequestMapping("/auth")
public class AuthenticationController {

    @Autowired
    private AuthenticationService authenticationService;

    @PostMapping("/application/loginByPwd")
    public ResponseResult<Map<String, String>> loginApplication(@RequestBody ApplicationVo applicationVo) {
        return authenticationService.loginApplicationByPwd(applicationVo.getUsername(), applicationVo.getPassword());
    }

    @PostMapping("/application/logout")
    public ResponseResult<String> logoutApplication() {
        return authenticationService.logoutApplication();
    }
}
